<?

function xml2array($xmlobject) {
    if ($xmlobject) {
        foreach ((array) $xmlobject as $k => $v) {
            $data[$k] = !is_string($v) ? xml2array($v) : $v;
        }
        return $data;
    }
}

/* 一个分页函数可带其它参数
  'PID      页面中的其它传参连接
  'page     要显示的页码
  'Vcount   总记录数
  'Pnum     每页记录数
  'className    超连接样式
 */

function ThePage($Pid, $page = 1, $Vcount, $Pnum, $className) {
    $Pcount = ceil($Vcount / $Pnum);
    if ($page > $Pcount)
        $page = $Pcount;
    $StartPageNum = 1;
    while ($StartPageNum + 10 <= $page) {
        $StartPageNum = $StartPageNum + 10;
    }
    $EndPageNum = $StartPageNum + 9;
    if ($EndPageNum > $Pcount)
        $EndPageNum = $Pcount;
    $show = $show . "<tr><td colspan='10' bgcolor='' align='right' style='padding-right:25px;padding-top:5px;' class='" . $className . "'>";
    $show = $show . "共<b>" . $Pcount . "</b>页 共有<b>" . $Vcount . "</b>记录 第<b>" . $page . "</b>页 跳到第 [ ";
    if ($StartPageNum > 1)
        $show = $show . "<a class='" . $className . "' href='?" . $Pid . "page=" . ($StartPageNum - 1) . "' title='前十页'><font face='webdings'>7</font></a>";
    for ($go = $StartPageNum; $go <= $EndPageNum; $go++) {
        if ($go != $page) {
            $show = $show . "<a class='" . $className . "' href='?" . $Pid . "page=" . $go . "'>" . $go . "</a>";
        } else {
            $show = $show . "<b>" . $go . "</b>";
        }
        $show = $show . " ";
    }
    if ($EndPageNum < $Pcount)
        $show = $show . "<a class='" . $className . "' href='?" . $Pid . "page=" . ($EndPageNum + 1) . "' title='下十页'><font face='webdings'>8</font></a>";
    $show = $show . "] 页";
    if ($page != 1)
        $show = $show . "<a class='" . $className . "' href='?" . $Pid . "page=1'> 首页</a> <a class='" . $className . "' href='?" . $Pid . "page=" . ($page - 1) . "'>上一页</a>";
    if ($Pcount - $page != 0)
        $show = $show . "<a class='" . $className . "' href='?" . $Pid . "page=" . ($page + 1) . "'> 下一页</a> <a class='" . $className . "' href='?" . $Pid . "page=" . $Pcount . "'>尾页</a>";
    $show = $show . "</tr></td>";
    return $show;
}

?>
